package com.zygh.interactiveplatform.module.controller;


import com.alibaba.fastjson.JSONObject;
import com.zygh.interactiveplatform.common.anno.PcLog;
import com.zygh.interactiveplatform.common.constant.SwaggerTagConst;
import com.zygh.interactiveplatform.common.domain.ResponseDTO;
import com.zygh.interactiveplatform.module.entity.InvalidAnalysis;
import com.zygh.interactiveplatform.module.entity.InvalidAnalysis;
import com.zygh.interactiveplatform.module.service.InvalidAnalysisService;
import com.zygh.interactiveplatform.module.service.InvalidAnalysisService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lee
 * @since 2021-01-29
 */
@RestController
@RequestMapping("/invalid-analysis")
@Api(tags = {SwaggerTagConst.Admin.MANAGER_INVALIDANALYSIS})
public class InvalidAnalysisController {
    @Resource
    private InvalidAnalysisService invalidAnalysisService;

    @ApiOperation(value = "新增证据来源", notes = "新增证据来源")
    @PostMapping("addInvalidAnalysise")
    @PcLog(logType = "2", module = SwaggerTagConst.Admin.MANAGER_INVALIDANALYSIS, content = "新增证据来源")
    public ResponseDTO addInvalidAnalysise(@RequestBody @Valid InvalidAnalysis invalidAnalysis) {
        return invalidAnalysisService.addInvalidAnalysis(invalidAnalysis);
    }
    @ApiOperation(value = "修改证据来源", notes = "修改证据来源")
    @PostMapping("updateInvalidAnalysis")
    @PcLog(logType = "3", module = SwaggerTagConst.Admin.MANAGER_INVALIDANALYSIS, content = "修改证据来源")
    public ResponseDTO updateInvalidAnalysis(@RequestBody @Valid InvalidAnalysis invalidAnalysis) {
        return invalidAnalysisService.updateInvalidAnalysis(invalidAnalysis);
    }
    @ApiOperation(value = "删除证据来源", notes = "删除证据来源")
    @PostMapping("deleteInvalidAnalysis")
    @PcLog(logType = "4", module = SwaggerTagConst.Admin.MANAGER_INVALIDANALYSIS, content = "删除证据来源")
    public ResponseDTO deleteInvalidAnalysis(@RequestBody String id) {
        String s = JSONObject.parseObject(id).get("id").toString();
        Integer new_id = Integer.parseInt(s);
        return invalidAnalysisService.deleteInvalidAnalysis(new_id);
    }
    @ApiOperation(value = "查询所有证据来源", notes = "查询所有证据来源")
    @GetMapping("findInvalidAnalysisAll")
    @PcLog(logType = "1", module = SwaggerTagConst.Admin.MANAGER_INVALIDANALYSIS, content = "查询所有证据来源")
    public ResponseDTO findInvalidAnalysisAll(Integer current, Integer size) {
        return invalidAnalysisService.findInvalidAnalysisAll(current,size);
    }
}
